package com.ruoyi.web.controller.mall.menNeedUser.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.controller.mall.mallShopUser.domain.MallShopUser;
import com.ruoyi.web.controller.mall.mallShopUser.service.IMallShopUserService;
import com.ruoyi.web.controller.mall.menNeedInfo.domain.MenNeedInfo;
import com.ruoyi.web.controller.mall.menNeedUser.service.IMenNeedUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户领取需求Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/mall/menNeedUser")
public class MenNeedUserController extends BaseController
{
    @Autowired
    private IMenNeedUserService menNeedUserService;
    @Autowired
    private IMallShopUserService mallShopUserService;

    /**
     * 查询用户领取需求列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody MenNeedInfo menNeedInfo)
    {
        MallShopUser msu = mallShopUserService.selectMallShopUserById(menNeedInfo.getShopId());
        if (msu!=null){
            menNeedInfo.setShopId(msu.getUserId());
        }
        startPage();
        List<MenNeedInfo> list = menNeedUserService.selectMenNeedUserList(menNeedInfo);
        return getDataTable(list);
    }


    /**
     * 获取商品规格名详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        MenNeedInfo menNeedInfo = menNeedUserService.selectMenNeedUserById(id);
        return AjaxResult.success(menNeedInfo);
    }

}
